package cz.cvut.fit.web.nakupniSeznam.ws.conv;

import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;

import cz.cvut.fit.web.nakupniSeznam.data.Unit;

@XmlRootElement(name = "unit")
@XmlType(propOrder = { "id", "mobileId", "name", "lastChanged"})
public class UnitConverter {

	public UnitConverter() {
		this.unit = new Unit();
		this.mobileId = null;
	}

	public UnitConverter(Unit unit) {
		super();

		this.unit = unit;
		this.mobileId = null;
		// this.uri = repairUri(uri);
	}

	// private URI repairUri(URI uri) {
	// String s = uri.getPath().replaceFirst("/unit.*", "/unit/");
	// URI listUri = URI.create(s + this.unit.getId());
	// URI resolvedUri = uri.resolve(listUri);
	// return resolvedUri;
	// }
	//
	// private URI uri;

	private Unit unit;
	private Long mobileId;

	@XmlElement
	public Long getId() {
		return this.unit.getId();
		// return id;
	}

	@XmlElement
	public String getName() {
		return this.unit.getName();
	}

	public void setId(Long id) {
		this.unit.setId(id);
	}

	public void setName(String name) {
		this.unit.setName(name);
	}

	public Unit retrieveRepresentation() {
		return unit;
	}

	@XmlElement
	public Long getMobileId() {
		return mobileId;
	}

	public void setMobileId(Long mobileId) {
		this.mobileId = mobileId;
	}
	
	@XmlElement
	public Long getLastChanged() {
		return this.unit.getLastChanged();
	}
	
	public void setLastChanged(Long lastChanged) {
		this.unit.setLastChanged(lastChanged);
	}

}
